<!-- 事业部列表 -->
<template>
  <div class="app-container">
    <el-row v-hasPermi="['enterprise:enterprise:add']" :gutter="10" class="mb-8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleOpen()"
          >新增</el-button
        >
      </el-col>
      <right-toolbar
        :showSearch.sync="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="dataList">
      <el-table-column label="事业部名称" align="center" prop="dname" />
      <el-table-column label="事业部联系人" align="center" prop="contacts" />
      <el-table-column label="联系电话" align="center" prop="phone" />
      <el-table-column label="管理员姓名" align="center" prop="adminUser.nickName" />
      <el-table-column label="管理员账号" align="center" prop="adminUser.userName" />
      <el-table-column label="主要业务场景" align="center" prop="busineScene">
        <!-- 0自营 1中医下乡场景 2远程问诊场景 -->
        <template slot-scope="{row}">
          <dict-tag
            :options="dict.type.business_scene"
            :value="row.busineScene"
          />
        </template>
      </el-table-column>
      <el-table-column label="创建时间" align="center" prop="createTime" />
      <el-table-column
        label="操作"
        align="center"
        class-name="small-padding fixed-width"
        width="120px"
        fixed="right"
      >
        <template slot-scope="scope">
          <el-button v-hasPermi="['enterprise:enterprise:edit']" size="mini" type="text" @click="handleOpen(scope.row)"
            >编辑</el-button
          >
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <EditEnterprise  ref="EditEnterprise" @refresh="getList" />
  </div>
</template>

<script>
import { getDivisionList } from '@/api/facilitator';
import EditEnterprise from './editEnterprise'

export default {
  name: 'Enterprise',
  dicts: ['business_scene'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 显示搜索条件
      showSearch: true,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        keyword: "",
      },
      // 总条数
      total: 0,
      dataList: [],
    };
  },
  components: {
    EditEnterprise
  },
  created() {
    this.getList();
  },
  activated() {
    this.getList();
  },
  methods: {
    /** 查询列表 */
    getList() {
      this.loading = true;
      getDivisionList(this.queryParams)
        .then((response) => {
          this.dataList = response.rows;
          this.total = response.total;
        })
        .finally(() => {
          this.loading = false;
        });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    resetQuery() {
      Object.assign(this.$data.queryParams, this.$options.data().queryParams);
      this.getList();
    },
    handleOpen(row) {
      this.$refs.EditEnterprise.openModal(row);
    },
  },
};
</script>

<style lang="scss" scoped></style>
